<?php

/**
 * This is the model class for table "{{app_howtos}}".
 *
 * The followings are the available columns in table '{{app_howtos}}':
 * @property integer $howtos_id
 * @property integer $app_id
 * @property integer $admin_id
 * @property string $howtos_title
 * @property string $summary
 * @property string $content
 * @property string $ctime
 * @property string $mtime
 * @property string $status
 */
class AppHowtos extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AppHowtos the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{app_howtos}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('app_id, admin_id, howtos_title, ctime', 'required'),
			array('app_id, admin_id', 'numerical', 'integerOnly'=>true),
			array('howtos_title', 'length', 'max'=>255),
			array('status', 'length', 'max'=>7),
			array('summary, content, mtime', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('howtos_id, app_id, admin_id, howtos_title, summary, content, ctime, mtime, status', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'howtos_id' => 'Howtos',
			'app_id' => 'App',
			'admin_id' => 'Admin',
			'howtos_title' => 'Howtos Title',
			'summary' => 'Summary',
			'content' => 'Content',
			'ctime' => 'Ctime',
			'mtime' => 'Mtime',
			'status' => 'Status',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('howtos_id',$this->howtos_id);
		$criteria->compare('app_id',$this->app_id);
		$criteria->compare('admin_id',$this->admin_id);
		$criteria->compare('howtos_title',$this->howtos_title,true);
		$criteria->compare('summary',$this->summary,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('ctime',$this->ctime,true);
		$criteria->compare('mtime',$this->mtime,true);
		$criteria->compare('status',$this->status,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}